package com.clear.honghefinance.admin.controller;

import com.clear.honghefinance.biz.modules.system.member.domain.dto.GenerateMpRegCodeDTO;
import com.clear.honghefinance.biz.modules.system.member.domain.dto.PhoneRegisterDTO;
import com.clear.honghefinance.biz.modules.system.member.domain.vo.GenerateMpRegCodeVO;
import com.clear.honghefinance.biz.modules.system.member.service.IMemberRegisterService;
import com.clear.honghefinance.common.dto.entity.ApiResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 注册controller
 * </p>
 *
 * @author 程序员clear
 */
@Api(tags = "用户注册模块")
@RestController
@RequestMapping("/reg")
@Slf4j
public class RegisterController {

    @Resource
    private IMemberRegisterService memberRegisterService;

    /**
     * 手机号注册
     *
     * @param dto req
     * @return
     */
    @ApiOperation(value = "手机号注册")
    @PostMapping("/phoneReg")
    public ApiResponse<Long> phoneRegister(@Validated @RequestBody PhoneRegisterDTO dto) {
        return ApiResponse.success(memberRegisterService.phoneRegister(dto));
    }

    /**
     * 生成微信公众号二维码（关注微信公众号注册）
     *
     * @param dto req
     * @return 生成微信公众号二维码，供指定clientId使用
     */
    @ApiOperation(value = "生成微信公众号二维码")
    @GetMapping(value = "/generateMpRegCode")
    public ApiResponse<GenerateMpRegCodeVO> generateMpRegCode(@Validated @ModelAttribute GenerateMpRegCodeDTO dto) {
        GenerateMpRegCodeVO result = memberRegisterService.generateMpRegCode(dto.getClientId());
        return ApiResponse.success(result);
    }
}
